import { Component, OnInit, Output, EventEmitter } from '@angular/core';

import { HintsService } from '../../../../public/serve/hints/hints.service';
import { CudTableService } from 'app/public/serve/cud-table/cud-table.service';
import { Service } from '../../../../server/server';
import { appProductUrl } from '../../../product.url';
import { product } from '../../../product.data';
import {appThemeTagUrl} from '../../../../system/theme-tag/theme-tag.url';

declare var $: any;

@Component({
	selector: 'app-product-indexing-task-submit',
	templateUrl: './product-indexing-task-submit.component.html'
})
export class ProductIndexingTaskSubmitComponent implements OnInit {

	one: any;
	taskId: any;
	@Output() submitEvent = new EventEmitter<void>();

	constructor(
        private server: Service,
		private request: CudTableService,
		private hintsService: HintsService
	) { }

	ngOnInit() {
	}

	setData(taskData) {
		this.taskId = taskData.taskId;
	}

	/**
     * 送审(子任务)
     */
    public setSubmitStatus() {
        const params = {
            token: product.retrieval.token,
            taskId: this.taskId,
            status: "1"
        }
        this.request.postRequest(this.server.baseUrl +appProductUrl.setTaskSubmitStatus, params).then(res => {
            if (res.result_code === '0000') {
				this.submitEvent.emit();
            }
            this.hintsService.messages(res.message, res.result_code);
            return;
        }).catch((err: any) => {
            this.hintsService.messages('error', 'error');
            return;
        });
    }
}
